\section{domain.\+c File Reference}
\label{domain_8c}\index{domain.\+c@{domain.\+c}}


Ether\+C\+AT domain methods.  


\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{domain_8c_a06f1befc7d03dbef13e823d26863aec4}} 
\#define \textbf{ D\+E\+B\+U\+G\+\_\+\+R\+E\+D\+U\+N\+D\+A\+N\+CY}~0
\begin{DoxyCompactList}\small\item\em Extra debug output for redundancy functions. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \textbf{ ec\+\_\+domain\+\_\+clear\+\_\+data} (\textbf{ ec\+\_\+domain\+\_\+t} $\ast$domain)
\begin{DoxyCompactList}\small\item\em Frees internally allocated memory. \end{DoxyCompactList}\item 
void \textbf{ ec\+\_\+domain\+\_\+init} (\textbf{ ec\+\_\+domain\+\_\+t} $\ast$domain, \textbf{ ec\+\_\+master\+\_\+t} $\ast$master, unsigned int index)
\begin{DoxyCompactList}\small\item\em Domain constructor. \end{DoxyCompactList}\item 
void \textbf{ ec\+\_\+domain\+\_\+clear} (\textbf{ ec\+\_\+domain\+\_\+t} $\ast$domain)
\begin{DoxyCompactList}\small\item\em Domain destructor. \end{DoxyCompactList}\item 
void \textbf{ ec\+\_\+domain\+\_\+add\+\_\+fmmu\+\_\+config} (\textbf{ ec\+\_\+domain\+\_\+t} $\ast$domain, \textbf{ ec\+\_\+fmmu\+\_\+config\+\_\+t} $\ast$fmmu)
\begin{DoxyCompactList}\small\item\em Adds an F\+M\+MU configuration to the domain. \end{DoxyCompactList}\item 
int \textbf{ ec\+\_\+domain\+\_\+add\+\_\+datagram\+\_\+pair} (\textbf{ ec\+\_\+domain\+\_\+t} $\ast$domain, uint32\+\_\+t logical\+\_\+offset, size\+\_\+t data\+\_\+size, uint8\+\_\+t $\ast$data, const unsigned int used[$\,$])
\begin{DoxyCompactList}\small\item\em Allocates a domain datagram pair and appends it to the list. \end{DoxyCompactList}\item 
int \textbf{ shall\+\_\+count} (const \textbf{ ec\+\_\+fmmu\+\_\+config\+\_\+t} $\ast$cur\+\_\+fmmu, const \textbf{ ec\+\_\+fmmu\+\_\+config\+\_\+t} $\ast$first\+\_\+fmmu)
\begin{DoxyCompactList}\small\item\em Domain finish helper function. \end{DoxyCompactList}\item 
int \textbf{ ec\+\_\+domain\+\_\+finish} (\textbf{ ec\+\_\+domain\+\_\+t} $\ast$domain, uint32\+\_\+t base\+\_\+address)
\begin{DoxyCompactList}\small\item\em Finishes a domain. \end{DoxyCompactList}\item 
\mbox{\label{domain_8c_a7af777c7a15fc667d283794dcf2cc498}} 
unsigned int \textbf{ ec\+\_\+domain\+\_\+fmmu\+\_\+count} (const \textbf{ ec\+\_\+domain\+\_\+t} $\ast$domain)
\begin{DoxyCompactList}\small\item\em Get the number of F\+M\+MU configurations of the domain. \end{DoxyCompactList}\item 
const \textbf{ ec\+\_\+fmmu\+\_\+config\+\_\+t} $\ast$ \textbf{ ec\+\_\+domain\+\_\+find\+\_\+fmmu} (const \textbf{ ec\+\_\+domain\+\_\+t} $\ast$domain, unsigned int pos)
\begin{DoxyCompactList}\small\item\em Get a certain F\+M\+MU configuration via its position in the list. \end{DoxyCompactList}\item 
int \textbf{ ecrt\+\_\+domain\+\_\+reg\+\_\+pdo\+\_\+entry\+\_\+list} (\textbf{ ec\+\_\+domain\+\_\+t} $\ast$domain, const \textbf{ ec\+\_\+pdo\+\_\+entry\+\_\+reg\+\_\+t} $\ast$regs)
\begin{DoxyCompactList}\small\item\em Registers a bunch of P\+DO entries for a domain. \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ ecrt\+\_\+domain\+\_\+size} (const \textbf{ ec\+\_\+domain\+\_\+t} $\ast$domain)
\begin{DoxyCompactList}\small\item\em Returns the current size of the domain\textquotesingle{}s process data. \end{DoxyCompactList}\item 
void \textbf{ ecrt\+\_\+domain\+\_\+external\+\_\+memory} (\textbf{ ec\+\_\+domain\+\_\+t} $\ast$domain, uint8\+\_\+t $\ast$mem)
\begin{DoxyCompactList}\small\item\em Provide external memory to store the domain\textquotesingle{}s process data. \end{DoxyCompactList}\item 
uint8\+\_\+t $\ast$ \textbf{ ecrt\+\_\+domain\+\_\+data} (\textbf{ ec\+\_\+domain\+\_\+t} $\ast$domain)
\begin{DoxyCompactList}\small\item\em Returns the domain\textquotesingle{}s process data. \end{DoxyCompactList}\item 
void \textbf{ ecrt\+\_\+domain\+\_\+process} (\textbf{ ec\+\_\+domain\+\_\+t} $\ast$domain)
\begin{DoxyCompactList}\small\item\em Determines the states of the domain\textquotesingle{}s datagrams. \end{DoxyCompactList}\item 
void \textbf{ ecrt\+\_\+domain\+\_\+queue} (\textbf{ ec\+\_\+domain\+\_\+t} $\ast$domain)
\begin{DoxyCompactList}\small\item\em (Re-\/)queues all domain datagrams in the master\textquotesingle{}s datagram queue. \end{DoxyCompactList}\item 
void \textbf{ ecrt\+\_\+domain\+\_\+state} (const \textbf{ ec\+\_\+domain\+\_\+t} $\ast$domain, \textbf{ ec\+\_\+domain\+\_\+state\+\_\+t} $\ast$state)
\begin{DoxyCompactList}\small\item\em Reads the state of a domain. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Ether\+C\+AT domain methods. 



\subsection{Function Documentation}
\mbox{\label{domain_8c_acdb99d1f2a267eae55d21b2eb5ff0d06}} 
\index{domain.\+c@{domain.\+c}!ec\+\_\+domain\+\_\+clear\+\_\+data@{ec\+\_\+domain\+\_\+clear\+\_\+data}}
\index{ec\+\_\+domain\+\_\+clear\+\_\+data@{ec\+\_\+domain\+\_\+clear\+\_\+data}!domain.\+c@{domain.\+c}}
\subsubsection{ec\+\_\+domain\+\_\+clear\+\_\+data()}
{\footnotesize\ttfamily void ec\+\_\+domain\+\_\+clear\+\_\+data (\begin{DoxyParamCaption}\item[{\textbf{ ec\+\_\+domain\+\_\+t} $\ast$}]{domain }\end{DoxyParamCaption})}



Frees internally allocated memory. 


\begin{DoxyParams}{Parameters}
{\em domain} & Ether\+C\+AT domain. \\
\hline
\end{DoxyParams}


Definition at line 106 of file domain.\+c.

\mbox{\label{domain_8c_a541742767f0adada4d91f56f26d4250c}} 
\index{domain.\+c@{domain.\+c}!ec\+\_\+domain\+\_\+init@{ec\+\_\+domain\+\_\+init}}
\index{ec\+\_\+domain\+\_\+init@{ec\+\_\+domain\+\_\+init}!domain.\+c@{domain.\+c}}
\subsubsection{ec\+\_\+domain\+\_\+init()}
{\footnotesize\ttfamily void ec\+\_\+domain\+\_\+init (\begin{DoxyParamCaption}\item[{\textbf{ ec\+\_\+domain\+\_\+t} $\ast$}]{domain,  }\item[{\textbf{ ec\+\_\+master\+\_\+t} $\ast$}]{master,  }\item[{unsigned int}]{index }\end{DoxyParamCaption})}



Domain constructor. 


\begin{DoxyParams}{Parameters}
{\em domain} & Ether\+C\+AT domain. \\
\hline
{\em master} & Parent master. \\
\hline
{\em index} & Index. \\
\hline
\end{DoxyParams}


Definition at line 58 of file domain.\+c.

\mbox{\label{domain_8c_af4dd81f20a9fdb52e15b802afefd47d3}} 
\index{domain.\+c@{domain.\+c}!ec\+\_\+domain\+\_\+clear@{ec\+\_\+domain\+\_\+clear}}
\index{ec\+\_\+domain\+\_\+clear@{ec\+\_\+domain\+\_\+clear}!domain.\+c@{domain.\+c}}
\subsubsection{ec\+\_\+domain\+\_\+clear()}
{\footnotesize\ttfamily void ec\+\_\+domain\+\_\+clear (\begin{DoxyParamCaption}\item[{\textbf{ ec\+\_\+domain\+\_\+t} $\ast$}]{domain }\end{DoxyParamCaption})}



Domain destructor. 


\begin{DoxyParams}{Parameters}
{\em domain} & Ether\+C\+AT domain \\
\hline
\end{DoxyParams}


Definition at line 88 of file domain.\+c.

\mbox{\label{domain_8c_a5bd01575864546e8f5929752e54456b6}} 
\index{domain.\+c@{domain.\+c}!ec\+\_\+domain\+\_\+add\+\_\+fmmu\+\_\+config@{ec\+\_\+domain\+\_\+add\+\_\+fmmu\+\_\+config}}
\index{ec\+\_\+domain\+\_\+add\+\_\+fmmu\+\_\+config@{ec\+\_\+domain\+\_\+add\+\_\+fmmu\+\_\+config}!domain.\+c@{domain.\+c}}
\subsubsection{ec\+\_\+domain\+\_\+add\+\_\+fmmu\+\_\+config()}
{\footnotesize\ttfamily void ec\+\_\+domain\+\_\+add\+\_\+fmmu\+\_\+config (\begin{DoxyParamCaption}\item[{\textbf{ ec\+\_\+domain\+\_\+t} $\ast$}]{domain,  }\item[{\textbf{ ec\+\_\+fmmu\+\_\+config\+\_\+t} $\ast$}]{fmmu }\end{DoxyParamCaption})}



Adds an F\+M\+MU configuration to the domain. 


\begin{DoxyParams}{Parameters}
{\em domain} & Ether\+C\+AT domain. \\
\hline
{\em fmmu} & F\+M\+MU configuration. \\
\hline
\end{DoxyParams}


Definition at line 122 of file domain.\+c.

\mbox{\label{domain_8c_aff1ea02398e17bf036e69a594844da85}} 
\index{domain.\+c@{domain.\+c}!ec\+\_\+domain\+\_\+add\+\_\+datagram\+\_\+pair@{ec\+\_\+domain\+\_\+add\+\_\+datagram\+\_\+pair}}
\index{ec\+\_\+domain\+\_\+add\+\_\+datagram\+\_\+pair@{ec\+\_\+domain\+\_\+add\+\_\+datagram\+\_\+pair}!domain.\+c@{domain.\+c}}
\subsubsection{ec\+\_\+domain\+\_\+add\+\_\+datagram\+\_\+pair()}
{\footnotesize\ttfamily int ec\+\_\+domain\+\_\+add\+\_\+datagram\+\_\+pair (\begin{DoxyParamCaption}\item[{\textbf{ ec\+\_\+domain\+\_\+t} $\ast$}]{domain,  }\item[{uint32\+\_\+t}]{logical\+\_\+offset,  }\item[{size\+\_\+t}]{data\+\_\+size,  }\item[{uint8\+\_\+t $\ast$}]{data,  }\item[{const unsigned int}]{used[$\,$] }\end{DoxyParamCaption})}



Allocates a domain datagram pair and appends it to the list. 

The datagrams\textquotesingle{} types and expected working counters are determined by the number of input and output fmmus that share the datagrams.


\begin{DoxyRetVals}{Return values}
{\em 0} & Success. \\
\hline
{\em $<$0} & Error code. \\
\hline
\end{DoxyRetVals}

\begin{DoxyParams}{Parameters}
{\em domain} & Ether\+C\+AT domain. \\
\hline
{\em logical\+\_\+offset} & Logical offset. \\
\hline
{\em data\+\_\+size} & Size of the data. \\
\hline
{\em data} & Process data. \\
\hline
{\em used} & Slave config counter for in/out. \\
\hline
\end{DoxyParams}


Definition at line 147 of file domain.\+c.

\mbox{\label{domain_8c_acb9f97fed0d3173fb741b64afd115602}} 
\index{domain.\+c@{domain.\+c}!shall\+\_\+count@{shall\+\_\+count}}
\index{shall\+\_\+count@{shall\+\_\+count}!domain.\+c@{domain.\+c}}
\subsubsection{shall\+\_\+count()}
{\footnotesize\ttfamily int shall\+\_\+count (\begin{DoxyParamCaption}\item[{const \textbf{ ec\+\_\+fmmu\+\_\+config\+\_\+t} $\ast$}]{cur\+\_\+fmmu,  }\item[{const \textbf{ ec\+\_\+fmmu\+\_\+config\+\_\+t} $\ast$}]{first\+\_\+fmmu }\end{DoxyParamCaption})}



Domain finish helper function. 

Detects, if a slave configuration has already been taken into account for a datagram\textquotesingle{}s expected working counter calculation.

Walks through the list of all F\+M\+MU configurations for the current datagram and ends before the current datagram.

\begin{DoxyReturn}{Returns}
Non-\/zero if slave connfig was already counted. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em cur\+\_\+fmmu} & Current F\+M\+MU with direction to search for. \\
\hline
{\em first\+\_\+fmmu} & Datagram\textquotesingle{}s first F\+M\+MU. \\
\hline
\end{DoxyParams}


Definition at line 195 of file domain.\+c.

\mbox{\label{domain_8c_a2d8b30e08d2cd063b5e55e07e54c8852}} 
\index{domain.\+c@{domain.\+c}!ec\+\_\+domain\+\_\+finish@{ec\+\_\+domain\+\_\+finish}}
\index{ec\+\_\+domain\+\_\+finish@{ec\+\_\+domain\+\_\+finish}!domain.\+c@{domain.\+c}}
\subsubsection{ec\+\_\+domain\+\_\+finish()}
{\footnotesize\ttfamily int ec\+\_\+domain\+\_\+finish (\begin{DoxyParamCaption}\item[{\textbf{ ec\+\_\+domain\+\_\+t} $\ast$}]{domain,  }\item[{uint32\+\_\+t}]{base\+\_\+address }\end{DoxyParamCaption})}



Finishes a domain. 

This allocates the necessary datagrams and writes the correct logical addresses to every configured F\+M\+MU.

\begin{DoxyRefDesc}{Todo}
\item[\textbf{ Todo}]Check for F\+M\+M\+Us that do not fit into any datagram.\end{DoxyRefDesc}



\begin{DoxyRetVals}{Return values}
{\em 0} & Success \\
\hline
{\em $<$0} & Error code. \\
\hline
\end{DoxyRetVals}

\begin{DoxyParams}{Parameters}
{\em domain} & Ether\+C\+AT domain. \\
\hline
{\em base\+\_\+address} & Logical base address. \\
\hline
\end{DoxyParams}


Definition at line 226 of file domain.\+c.

\mbox{\label{domain_8c_a3f9bffd81ad553290bf06b7406d08e6b}} 
\index{domain.\+c@{domain.\+c}!ec\+\_\+domain\+\_\+find\+\_\+fmmu@{ec\+\_\+domain\+\_\+find\+\_\+fmmu}}
\index{ec\+\_\+domain\+\_\+find\+\_\+fmmu@{ec\+\_\+domain\+\_\+find\+\_\+fmmu}!domain.\+c@{domain.\+c}}
\subsubsection{ec\+\_\+domain\+\_\+find\+\_\+fmmu()}
{\footnotesize\ttfamily const \textbf{ ec\+\_\+fmmu\+\_\+config\+\_\+t}$\ast$ ec\+\_\+domain\+\_\+find\+\_\+fmmu (\begin{DoxyParamCaption}\item[{const \textbf{ ec\+\_\+domain\+\_\+t} $\ast$}]{domain,  }\item[{unsigned int}]{pos }\end{DoxyParamCaption})}



Get a certain F\+M\+MU configuration via its position in the list. 

\begin{DoxyReturn}{Returns}
F\+M\+MU at position {\itshape pos}, or N\+U\+LL. 
\end{DoxyReturn}

\begin{DoxyParams}{Parameters}
{\em domain} & Ether\+C\+AT domain. \\
\hline
{\em pos} & List position. \\
\hline
\end{DoxyParams}


Definition at line 350 of file domain.\+c.

